# -*- coding: utf-8 -*-

import sqlite3
import csv
'''
conexao = sqlite3.connect('teste.db')
c = conexao.cursor()
c.execute('DROP TABLE IF EXISTS disc')
c.execute('CREATE TABLE disc(nome text, nota number)')
conexao.commit()

notas = [('P1', 14), ('P2', 16), ('LP', 19),('EDA', 11)]
c.executemany('INSERT INTO disc VALUES(?,?)', notas)

conexao.commit()
c.execute("SELECT * FROM disc WHERE nota > 16")
print "uma...", c.fetchone()

k = 0; soma = 0.0

for linha in c.execute("SELECT * FROM disc"):
    print linha; soma += linha[1]; k += 1

print "media = {:2.2f}".format(soma/k)
conexao.close()
'''

with open('notas.csv', 'rb') as csvfile:
    csvfile.next()
    leitor = csv.reader(csvfile)
    valores=[]
    
    for linha in leitor:
        valores.append(int(linha[1]))

cavg = sum(valores)/len(valores)
print (" Media: " + str(cavg))
        
